package pres.lnk.learn.designpattern.b_abstractfactory;

import pres.lnk.learn.designpattern.b_abstractfactory.mysql.MysqlFactory;
import pres.lnk.learn.designpattern.b_abstractfactory.oracle.OracleFactory;

/**
 * <p>抽象工厂</p>
 * <pre>
 * 抽象工厂是简单工厂的打包版，简单工厂只能生成单一的一个产品，而抽象工工厂的工厂
 *
 * </pre>
 * @Author lnk
 * @Date 2018/1/31
 */
public class Main {
    public static void main(String[] args) {
        //使用Mysql工厂
        DatabaseFactory factory = new MysqlFactory();
        //使用mysql查询
        Action action = factory.getAction("select");
        action.execute();
        //使用mysql更新
        action = factory.getAction("update");
        action.execute();

        //使用Oracle工厂
        factory = new OracleFactory();
        //使用Oracle查询
        action = factory.getAction("select");
        action.execute();
        //使用Oracle更新
        action = factory.getAction("update");
        action.execute();
    }
}
